package com.example.demo5.info.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.demo5.info.mapper.UserlistMapper;
import com.example.demo5.info.pojo.Userlist;
import com.example.demo5.info.service.UserlistService;
import com.example.demo5.result.AjaxResult;
import com.sun.org.apache.bcel.internal.generic.NEW;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;

@Service
public class UserlistServiceImpl extends ServiceImpl<UserlistMapper,Userlist>implements UserlistService{
    @Resource
    private  UserlistMapper userlistMapper;
    @Override
    public AjaxResult getList(int page, int size, String userName) {
        QueryWrapper<Userlist> userlistQueryWrapper=new QueryWrapper<>();
        if(!StringUtils.isEmpty(userName)){
            userlistQueryWrapper.like("user_name",userName);
        }
        //设置分页
        Page<Userlist> userlistPage= new Page<>(page,size);
        Page<Userlist> userlistPage1=userlistMapper.selectPage(userlistPage,userlistQueryWrapper);
        return AjaxResult.success(userlistPage1);
    }
}
